package br.com.neb.caronamanager.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.neb.caronamanager.R;
import br.com.neb.caronamanager.model.NavDrawerItem;

public class NavDrawerItemAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<NavDrawerItem> items;
	
	public NavDrawerItemAdapter(Context context, ArrayList<NavDrawerItem> items)
	{
		this.context = context;
		this.items = items;
	}
	
	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null)
		{
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.drawer_list_item, null);
		}
		
		TextView title = (TextView) convertView.findViewById(R.id.title);
		title.setText(items.get(position).getTitle());
		
		return convertView;
	}

}
